package com.deyuanyun.pic.pipe.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.deyuanyun.pic.common.util.ajax.AjaxSupport;
import com.deyuanyun.pic.pipe.domain.MapTagging;
import com.deyuanyun.pic.pipe.service.MapTaggingService;
import com.deyuanyun.pic.settings.controller.dto.UserSessionVO;
import com.deyuanyun.pic.settings.support.cache.SessionCacheSupport;

/**
 *  地图标注服务
 * @author ChenKui
 *
 */
@Controller
@RequestMapping("/pipe/MapTagging")
public class MapTaggingController extends PipeBaseController {

    
    private @Resource MapTaggingService mapTaggingService;
    
    /**
     * 根据id查询 环焊缝无损检测信息 详情
     *
     * @param id
     */
    @RequestMapping("/queryList.json")
    @ResponseBody
    public void queryList(@RequestParam("type") String type) {
        UserSessionVO userSession = SessionCacheSupport.getSessionVO();
        String userId = userSession.getId();
        
        List<MapTagging> list = mapTaggingService.queryMapTagging(userId, type);
        
        AjaxSupport.sendSuccessText("",list);
    }
    
    

    /**
     * 根据id查询 环焊缝无损检测信息 详情
     *
     * @param id
     */
    @RequestMapping("/createOrUpdate.json")
    @ResponseBody
    public void createOrUpdate(MapTagging mapTagging,ModelMap model) {
        UserSessionVO userSession = SessionCacheSupport.getSessionVO();
        String userId = userSession.getId();
        mapTagging.setUserId(userId);
        int r = mapTaggingService.createOrUpdate(mapTagging);
        model.addAttribute("count", r);
        AjaxSupport.sendSuccessText("",model);
    }
    

    /**
     * 根据id查询 环焊缝无损检测信息 详情
     *
     * @param id
     */
    @RequestMapping("/updateToDelete.json")
    @ResponseBody
    public void updateToDelete(@RequestParam("mtid") String mtid,ModelMap model) {
        
        int r = mapTaggingService.updateToDelete(mtid);

        model.addAttribute("count", r);
        AjaxSupport.sendSuccessText("",model);
    }
    
    
    
}
